import java.util.ArrayList;

public class Game {
    private ArrayList<Integer> list;
    private int index;//下标
    private int count;
    public Game(ArrayList<Integer> array) {//构造方法
        this.list = new ArrayList<>(array);
    }
    {
        index = 0;
        count = 0;
    }
    public int initiate() {
        while(list.size() > 1) {
            for(int i = 0; i < list.size();i++) {
                count++;
                if(count == 4) {
                    list.remove(i);
                    count = 0;
                    if(i > 0) {
                        i--;
                    }else {
                        i = list.size() - 1;
                    }
                }
            }
        }
        return list.get(0);
    }
}
